import 'package:fluro_decorate/fluro_decorate.dart';
import 'package:flutter/material.dart';

///
/// @ProjectName:    fluro_demo
/// @Package:
/// @ClassName:      main_page
/// @Description:    dart文件作用
/// @Author:         WTT
/// @CreateDate:     2021/10/27 5:58 下午
class MainPage extends StatefulWidget {
  final Bundle bundle;

  MainPage({this.bundle});

  @override
  State<StatefulWidget> createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  Bundle _bundle;

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text("我是首页"),
            if (widget.bundle != null)
              Text("bundle:${widget.bundle.toString()}"),
            if (_bundle != null) Text("_bundle:${_bundle.toString()}"),
            Container(
              child: TextButton(
                  child: Text("返回"),
                  onPressed: () {
                    Bundle bundle = Bundle();
                    bundle.putBool("bool", true);
                    bundle.putInt("int", DateTime.now().second);
                    bundle.putString("string", DateTime.now().toString());
                    NavigatorUtil.pop(context, bundle: bundle);
                  }),
            ),
            Container(
              child: TextButton(
                child: Text("第一页"),
                onPressed: () {
                  Bundle bundle = Bundle();
                  bundle.setRoutePage("/one");
                  bundle.putInt("id", 123);
                  NavigatorUtil.push(context, bundle: bundle).then((value) {
                    setState(() {
                      _bundle = value;
                    });
                  });
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
}
